The 'KCHR' Resource
The 'KCHR' Resource
The 'KCHR' resource specifies the mapping of virtual key codes to character
codes (for example, ASCII). Each installed script system has one or more
'KCHR' resources; there may be one or more for each language or region to
suit the preference of the user. The resource ID for each 'KCHR' resource is in
the script's resource number range. The default 'KCHR' resource for a script
is specified by the script's 'itlb' resource. For more on virtual key codes, see
the Event Manager. The Rez file SysTypes.r contains the Rez type definitons
for the 'KCHR' resource
Note: Prior to system software version 7.0, an application could
force a script system to load a 'KCHR' resource that only existed
inside its resource fork. Since 'KCHR' resources are used across the
system (that is, are not application- specific), this was an extremely
undesirable situation. If an application failed to restore the
appropriate script system variables properly when it terminated or
was switched into the background, the
Script Manager attempted to find a 'KCHR' resource that was no
longer available.
With version 7.0, the Script Manager has been revised to load only 'KCHR'
resources that are installed in the System file. However, if your application
needs to modify the keyboard layout temporarily without forcing users to
install a new keyboard, you should load a 'KCHR' resource from your resource
fork and pass a pointer to that 'KCHR' resource directly to the _KeyTrans trap.
The Figure below shows the parts of the 'KCHR' resource and how they are
used. First, the modifier state information-8 bits, each indicating the state of
one modifier key-is treated as a byte that is mapped through a 256-byte
table-selection table to a table code. The table code specifies which of several
128-byte mapping tables is used to map the virtual key code to a
character-code byte. If the mapping table has a nonzero entry for a particular
virtual key code, that entry is the desired character code. If the entry is 0, the
dead-key tables are searched for a match with the virtual key code. If there is
a match, dead-key state information is set that affects how the next virtual key
code is processed, but no event is posted.
Inside the 'KCHR' resource
With system software version 7.0, the following changes in the U.S. 'KCHR'
resource (0) have been introduced for greater consistency:
Since the Shift key is ignored if the Command key is pressed, the
'KCHR' resource has been changed so the Caps Lock key is also ignored
if the Command key is pressed.
The Table below lists the changes in the handling of Option-Shift-key
and Option-Caps Lock-key combinations. These changes are based on
the following principles:
•If either the Option-key or the Option-Shift-key combination
produces a letter, then the Option-Caps Lock-key combination should
produce the same character as the Option-key, not the
Option-Shift-key, combination.
•If the Option-key combination is a dead key for a particular accent,
then the Option-Shift-key combination produces the accent directly.
System 7.0 also includes some changes in default dead-key
completers, so that the completer is a "real" accent character instead
of a low-ASCII approximation. The default completer is used when a
dead key is entered, but the following key is either a space or a key for
a character that cannot take the accent corresponding to the dead key.
The next Table after the one immediately below summarizes these
changes.
Changes in handling 'KCHR' (0) key combinations
Key Old New
combination character character Reason
Option-Caps Lock-E ‰ ´ Acute accent for dead-key
Option-E
Option-Caps Lock-G Ì © Be like Option-G, not
Option-Shift-G
Option-Caps Lock-I È ˆ Circumflex accent for dead-key
Option-I
Option-Caps Lock-K [Missing image]F0) [TOKEN:44736]Be like Option-K, not
Option-Shift-K
Option-Caps Lock-M ˜ Â
Option-Caps Lock-N ˆ ˜ Tilde accent for dead-key
Option-N
Option-Caps Lock-R Â ® Be like Option-R, not
Option-Shift-R
Option-Caps Lock-T Ê † Be like Option-T, not
Option-Shift-T
Option-Caps Lock-U Ë ¨ Umlaut for dead-key Option-U
Option-Caps Lock-V ´Be like Option-V, not
Option-Shift-V
Option-Caps Lock-W (0xE3) ∑ Be like Option-W, not
Option-Shift-W
Option-Caps Lock-X (0xC5) ´Be like Option-X, not
Option-Shift-X
Option-Caps Lock-Z (0xBD) [TOKEN:16997] like Option-Z, not
Option-Shift-Z
Option-Shift-E (0xE4) ´ Acute accent for dead-key
Option-E
Option-Shift-G Ì (0xFD) Make ( double-acute accent)
available for keyboard
Option-Shift-I È (0xF6) Circumflex accent for dead-key
Option-I
Option-Shift-M ˜ (0xF7) Â
Option-Shift-N ˆ (0xF6) ˜ (0xF7) Tilde accent for dead-key
Option-N
Option-Shift-R Â ‰ Moved from Option-Shift-E
Option-Shift-T Ê (0xFF) Make (hacek) available from
keyboard
Option-Shift-U Ë ¨ Umlaut for dead-key Option-U
Option-Shift-X (0xFE) [TOKEN:8363]Make (ogonek) available for
keyboard
Option-Shift-Z (0xFC) [TOKEN:19809]ke [TOKEN:8384](cedilla) available for
keyboard
Option-Shift-` Ÿ ` Grave accent for dead key
Option-`
Changes in 'KCHR' dead-key completers
Old default New default
Dead key completer completer
Option-N ~ (0x7E) ˜ (0xF7)
Option-U ^ (0x5E) ˆ (0xF6)